<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>

<script>
    // 数组定义
    {
        var arr1 = new Array(1, 2, 4);
        var arr2 = [2, 4, 6];
        var arr3 = new Array(10);

        document.write(arr1 + "<br>");
        document.write(arr2+ "<br>");
        document.write(arr3+ "<br>");
    }

    // 数组元素
    document.write("<hr>数组元素<br>")
    {
        var arr1 = new Array(1, "test", ["a", 2]);
        document.write(arr1 + "<br>");
    }

    // 数组长度
    document.write("<hr>数组长度<br>")
    {
        var arr1 = new Array(1, "test");
        document.write(arr1 + "<br>");
        document.write("lent=" + arr1.length + "<br>");

        // 数组长度变为11，数组长度可变
        arr1[10] = 1;
        document.write("lent=" + arr1.length + "<br>");
    }

    // 数组拼接
    document.write("<hr>数组拼接<br>")
    {
        var arr1 = new Array(1, "test", ["a", 2]);
        document.write("join="+ arr1.join() + "<br>")
        document.write("join="+ arr1.join(":") + "<br>")
    }

    // 数组添加
    document.write("<hr>数组添加<br>")
    {
        var arr1 = new Array(1, "test", ["a", 2]);
        document.write("join="+ arr1.join() + "<br>")
        arr1.push("haha")
        document.write("join="+ arr1.join("+") + "<br>")
    }
</script>
</html>